import { TypeOrmModuleOptions } from '@nestjs/typeorm'
import { writeFileSync } from 'fs'
import { join } from 'path'

import utils from '../common/utils'

export function getDataBase() {
  let mysql: TypeOrmModuleOptions = {
    type: 'mysql',
    host: process.env.MYSQLHOST || '127.0.0.1',
    port: Number(process.env.MYSQLPORT) || 3306,
    username: process.env.MYSQLUSER || 'root',
    password: process.env.MYSQLPASSWORD || '123456',
    database: process.env.MYSQLDATABASE || 'coconut_uat',
    entities: [`${__dirname}/../entity/**/*.{js,ts}`],
    synchronize: false,
    logging: ["error"],
  }
  return mysql
}